package com.haier.npt.security.resource;

import java.math.BigInteger;
import java.util.List;

import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import com.haier.npt.common.JsonResult;
import com.haier.npt.page.PageBean;
import com.haier.npt.security.domain.SysPermission;
import com.haier.npt.security.domain.SysRole;
import com.haier.npt.security.domain.SysRoleMemberRe;
import com.haier.npt.security.dto.SysRoleDTO;
import com.haier.npt.security.dto.SysRoleSystemDTO;


public interface SysRoleResource {

    /**
     * 根据当前登录人查询当前登录人的权限
     * @param userId
     * @return
     */
    @RequestMapping(value = "/internal/members/permissions/listByUserId", method = RequestMethod.GET)
    JsonResult<List<SysPermission>> listPermissionByUserId(@RequestParam(value = "userId") Long userId, @RequestParam(value = "token") String token);

    /**
     * 添加一个角色
     * @param sysRole  角色对象
     * @return
     */
    @RequestMapping(value = "/internal/roles/add", method = RequestMethod.POST)
    JsonResult<Long> addrole(@RequestBody SysRole sysRole);
    
    /**
     * 添加一个管理员角色
     * @param sysRoleSystemDTO 角色信息
     * @return
     */
    @RequestMapping(value = "/internal/roles/addRoleSystem", method = RequestMethod.POST)
    JsonResult<Long> addRoleSystem(@RequestBody SysRoleSystemDTO sysRoleSystemDTO);
    /**
     * 根据角色编号删除角色
     *
     * @param roleId   角色id
     * @return
     */
    @RequestMapping(value = "/internal/roles/{roleId}/delete", method = RequestMethod.POST)
    JsonResult<Boolean> deleteRole(@PathVariable(value = "roleId") Long roleId);



    /**
     * 根据角色编号更新角色名
     *
     * @param roleId
     * @param roleName
     * @return
     */
    @RequestMapping(value = "/internal/roles/{roleId}/editName", method = RequestMethod.POST)
    JsonResult<Boolean> editRoleName(@PathVariable(value = "roleId") Long roleId,
                                     @RequestParam(value = "roleName") String roleName);


    /**
     * 给memberid 赋予多个角色
     * @param memberId 成员编号
     * @param roleIds  角色编号
     * @return
     */
    @RequestMapping(value = "/internal/members/grantRoleBatch", method = RequestMethod.POST)
    JsonResult<Boolean> addMemberRoles(@RequestParam(value = "memberId") Long memberId, @RequestParam(value = "roleIds[]") Long roleIds[]);

    /**
     * 批量获取成员的所有角色
     *
     * @param memberIds
     * @return
     */
    @RequestMapping(value = "/internal/members/list", method = RequestMethod.POST)
    JsonResult<List<SysRoleDTO>> listMemberRoles(@RequestParam(value = "memberIds[]") Long memberIds[]);


    /**
     * 角色添加成员
     *
     * @param roleId    角色编号
     * @param memberIds 成员编号
     * @return
     */
    @RequestMapping(value = "/internal/roles/{roleId}/members/addBatch", method = RequestMethod.POST)
    JsonResult<Boolean> addRoleMember(@PathVariable(value = "roleId") Long roleId, @RequestParam(value = "memberIds[]") Long memberIds[]);


    /**
     * 角色删除成员
     *
     * @param roleId    角色编号
     * @param memberIds 成员编号
     * @return
     */
    @RequestMapping(value = "/internal/roles/{roleId}/members/deleteBatch", method = RequestMethod.POST)
    JsonResult<Boolean> deleteRoleMember(@PathVariable(value = "roleId") Long roleId, @RequestParam(value = "memberIds[]") Long memberIds[]);

    /**
     * 根据角色编号查询此角色下的所有成员集合(分页)
     *
     * @param roleId
     * @return
     */
    @RequestMapping(value = "/internal/roles/{roleId}/members/list", method = RequestMethod.GET)
    JsonResult<PageBean<SysRoleMemberRe>> listMemberByRole(@PathVariable(value = "roleId") Long roleId,
                                                           @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize, @RequestParam(value = "pageIndex", defaultValue = "1") Integer pageIndex);


    /**
     * 根据成员编号删除对应的角色关系
     *
     * @param memberIds 成员编号
     * @return
     */
    @RequestMapping(value = "/internal/members/revokeAllRoleBatch", method = RequestMethod.POST)
    JsonResult<Boolean> deleteRoleMembers(@RequestParam(value = "memberIds[]") Long memberIds[]);


    /**
     * 角色添加权限
     *
     * @param roleId         角色编号
     * @param sysPermissions 权限集合
     * @return
     */
    @RequestMapping(value = "/internal/roles/{roleId}/permissions/addBatch", method = RequestMethod.POST)
    JsonResult<Boolean> addRolePermission(@PathVariable(value = "roleId") Long roleId,
                                          @RequestBody List<SysPermission> sysPermissions);


    /**
     * 角色删除权限
     * @param roleId        角色编号
     * @param permissionIds 权限ID集合
     * @return
     */
    @RequestMapping(value = "/internal/roles/{roleId}/permissions/deletebatch", method = RequestMethod.POST)
    JsonResult<Boolean> deleteRolePermission(@PathVariable(value = "roleId") Long roleId, @RequestParam(value = "permissionIds[]") Long[] permissionIds);

    /**
     * 根据角色ID查询关联的权限ID集合
     * @param roleId
     * @return
     */
    @RequestMapping(value = "/internal/roles/{roleId}/permissions/listIds", method = RequestMethod.POST)
    JsonResult<List<Long>> listRolePermissionIds(@PathVariable(value = "roleId") Long roleId);



    /**
     * 根据角色ID查询角色信息 
     *
     * @param roleId   角色ID
     * @return
     */
    @RequestMapping(value = "/internal/roles/{roleId}/get", method = RequestMethod.GET)
    JsonResult<SysRole> getSysRoleById( @PathVariable(value = "roleId") Long roleId);
}
